<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Maintenance Requests</title>
<?php
	include('Connection.php');
?>

<script>
	function gather_cars_by_location(val){
		var request = new XMLHttpRequest();
		request.onreadystatechange = function(){
			if(request.readyState == 4 && request.status == 200){
				$choose_car = document.getElementById("choose_car").innerHTML = request.responseText;
			}
		}
		request.open("GET", "manage_cars_populate.php?q="+val, true);
		request.send();
	}//end function gather_cars_by_location
</script>
</head>

<body>
	<h1>Maintenance Requests</h1>
	Date: <?php
		$date = date('d/m/Y - h:ia');
		 echo $date ?><br /><br />
    
    <form name='maint' method='post' action='maint_req_process.php'>
    	Choose Location: 
         <select name="car_location" onchange="gather_cars_by_location(this.value)">
              <?php
			  //query database for all car locations
			  $query = "SELECT LocationName FROM location GROUP BY LocationName;";									
			  $result = mysql_query($query);
										
			  while($row = mysql_fetch_assoc($result)){
    		  	echo '<option value="'.$row['LocationName'].'">'.$row[LocationName].'</option>';
			  }
			 ?>
                    </select><br /><br />
                    
          Car Model: 
                    <select name="choose_car" id="choose_car"></select><br /><br />
                    
          Brief Description of Problem:<br />
          <textarea name="prob"></textarea><br /><br />
          
          <input type="submit" value="Submit Request">
    </form>
</body>
</html>